﻿using ArtMath.Component;
using System;
using System.ComponentModel;

namespace ArtMath.Parameter
{
    [Serializable]
    public abstract class CalculatedParameter : ReadOnlyParameter
    {
        [Browsable(false)]
        public ToolTypeName ParamType { get; }
        [Browsable(false)]
        public SketchPad Pad { get; }
        public CalculatedParameter(SketchPad pad, string name, ToolTypeName type) : base(pad.Document, name, "0")
        {
            Pad = pad;//当关联组件改变时，新组件必须是和旧组件同一画板中的组件
            ParamType = type;
            Pad.Parameters.Add(this);
        }
        public abstract double GetNewValue();
        public override void Delete(bool recoverable = false)
        {
            base.Delete(recoverable);
            if (recoverable)
            {

            }
            else
            {
                Pad.Parameters.Remove(this);
            }
        }
    }
}
